import $http from '@/utils/request'
import dayjs from 'dayjs'
const endTime = dayjs(new Date().valueOf()).format('YYYY-MM-DD')
export function loginAPI(data) {
  return $http({
    url: '/api/user-service/user/login',
    method: 'POST',
    data
  })
}
// 人员搜索
export const userAPI = (params) => {
  return $http({
    url: '/api/user-service/user/search',
    params
  })
}

export const regionAPI = () => {
  return $http({
    url: '/api/vm-service/region/search?pageIndex=1&pageSize=100000'
  })
}
// 添加人员
export const addUserAPI = (data) => {
  return $http({
    url: 'api/user-service/user',
    method: 'POST',
    data
  })
}
// 修改人员
export const editUserAPI = (data, id) => {
  return $http({
    url: `/api/user-service/user/${id}`,
    method: 'PUT',
    data
  })
}
// 删除人员、
export const deleUserAPI = (id) => {
  return $http({
    url: `/api/user-service/user/${id}`,
    method: 'DELETE'
  })
}

// 人效统计 ---------------------------------------------
// 获取当时工单汇总信息(人员统计头部信息)
// /api/task-service/task/taskReportInfo/:start/:end
export const operationsStaffAPI = () => {
  return $http({
    url: `/api/task-service/task/taskReportInfo/${endTime} 00:00:00/${endTime} 23:59:59`
  })
}
// 工单状态
export const ticketStatusAPI = (startTime, endTime) => {
  return $http({
    url: `/api/task-service/task/collectReport/${startTime}/${endTime}`
  })
}
// 地区销售
export const regionalSalesAPI = () => {
  return $http({
    url: '/api/vm-service/region/search?pageIndex=1&pageSize=100000'
  })
}
// 人效排名
export const humanEfficiencyRankingAPI = (id, isbool) => {
  return $http({
    url: `/api/task-service/task/userWorkTop10/2022-10-01/${endTime}/${isbool}/${id}`
  })
}

// 工作量列表--------------------------------------

// 工作量列表
export const workloadAPI = (params) => {
  return $http({
    url: '/api/user-service/user/searchUserWork',
    params
  })
}
// 人员详情
export const personnelDetails = (id) => {
  return $http({
    url: `/api/user-service/user/${id}`
  })
}
// 本周
export const weekAPI = () => {
  return $http({
    url: `/api/task-service/task/userWork?userId=4&start=2022-10-17+00:00:00&end=${endTime}+23:59:59`
  })
}
// 本月
export const monthAPI = () => {
  return $http({
    url: `/api/task-service/task/userWork?userId=4&start=2022-10-01+00:00:00&end=${endTime}+23:59:59`
  })
}
// 本年
export const yearAPI = () => {
  return $http({
    url: `/api/task-service/task/userWork?userId=4&start=2022-01-01+00:00:00&end=${endTime}+23:59:59`
  })
}
